package com.quanxiaoha.xiaohashu.note.biz.consumer;


import com.quanxiaoha.xiaohashu.note.biz.constant.MQConstants;
import com.quanxiaoha.xiaohashu.note.biz.service.NoteDOService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * @Author: jingyan_liu
 * @CreateTime: 2025-08-05
 * @Description:
 * @Version: 1.0
 */


@Component
@Slf4j
@RocketMQMessageListener(consumerGroup = "xiaohashu_group", // Group
		topic = MQConstants.TOPIC_DELETE_NOTE_LOCAL_CACHE, // 消费的主题 Topic
		messageModel = MessageModel.BROADCASTING) // 广播模式
public class DeleteNoteLocalCacheConsumer implements RocketMQListener<String> {
	
	@Resource
	private NoteDOService noteService;
	
	@Override
	public void onMessage(String body) {
		Long noteId = Long.valueOf(body);
		noteService.deleteNoteLocalCache(noteId);
		log.info("## 消费者消费成功, noteId: {}", noteId);
	}
	
}